home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / cp1.zip / MOD1-2.C < prev    next >
C/C++ Source or Header  |  1993-06-10  |  3KB  |  128 lines

  1. ===========================================================================
  2.  BBS: The Abacus * HST/DS * Potterville, MI
  3. Date: 06-06-93 (11:26)             Number: 218
  4. From: DANIEL LYNES                 Refer#: NONE
  5.   To: MATTHEW O'CONNOR              Recvd: NO  
  6. Subj: Mod File Routines 2/4          Conf: (36) C Language
  7. ---------------------------------------------------------------------------
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <mem.h>
  11. #include <io.h>
  12. #include <fcntl.h>
  13. #include "MOD2.h"
  14.  
  15. /**************/
  16. /** Functions**/
  17. /**************/
  18.  
  19. void Print_Inst(struct S_Inst *inst)
  20. {
  21.  printf("Name         :%s\n",inst->Name);
  22.  printf("Lenght       :%u\n",inst->Len);
  23.  printf("Fine Tune    :%u\n",inst->F_Tune);
  24.  printf("Volume       :%u\n",inst->Vol);
  25.  printf("Repeat Start :%u\n",inst->R_Start);
  26.  printf("Repeat Length:%u\n",inst->R_Len);
  27. };
  28.  
  29. void Print_Note(struct S_Note *note)
  30. {
  31.  printf("Samp num: %.2i  ",note->Num);
  32.  printf("Perriod : %.4u  ",note->Period);
  33.  printf("Effect  : %.4u \n",note->Effect);
  34. };
  35.  
  36. void Print_Chan(struct S_Channel *chan)
  37. {
  38.  int i;
  39.  for ( i = 0; i < MAXCHAN ; i ++)
  40.  Print_Note(&chan->Chan[i]);
  41. };
  42.  
  43.  
  44. void Print_Track(struct S_Track *track)
  45. {
  46.  int c;
  47.  
  48.  for (c=0; c < MAXNOTES ; c++)
  49.   {
  50.    Print_Chan(&track->Note[c]);
  51.    printf("------------------------\n");
  52.   };
  53. };
  54. /*******************************/
  55. /****    Mod File Loading   ****/
  56. /**** Function Declarations ****/
  57. /*******************************/
  58.  
  59. word Con_Word(char *ptr)
  60. /* This function takes the word pointed to by ptr and switches
  61.   the high/low bytes to change from amiga to pc. It also multiplies
  62.   the result by two to convert words to bytes.   */
  63. {
  64.   word w;   /* temporary word  */
  65.   byte h,l; /* temporary bytes */
  66.  
  67.   h = *(ptr + 1);
  68.   l = *ptr;
  69.   w = (l * 256) + h;
  70.   w = w * 2; /* to convert # words to # of bytes. */
  71.   return(w);
  72. };
  73.  
  74. /*********
  75.  *********/
  76.  
  77. void Read_Note(struct S_Note *note, int handle)
  78. /* this function seperates the 4 bytes of a note into their
  79. propper catagories */
  80. {
  81.  char* ptr;
  82.  byte t[4];
  83.  
  84.  _read(handle,t,4);
  85.  
  86.  note->Num = (t[0]&240) + ((t[2]&240)/16);
  87.  /*          11110000       11110000 >> 00001111 */
  88.  note->Period  = (t[0]&15) * 256;
  89.  note->Period += t[1];
  90.  /*             00001111 << 111100000000     */
  91.  note->Effect  = (t[2]&15) *256;
  92.  note->Effect += t[3];
  93. };
  94.  
  95.  
  96. /*********
  97.  *********/
  98.  
  99. void Read_Inst (struct S_Inst *inst, int handle)
  100. /*  This function loades ONE instrament.  It puts the information into the inst
  101. structure.  "m_ptr" shows the function where the instrament starts at. */
  102.  
  103. {
  104.  char *cptr,       /* counting pointer  */
  105.  ptr;              /* temporary pointer */
  106.  int i;            /* temporary integer */
  107.  char t[30];       /* temporary buffer  */
  108.  
  109.  _read(handle,t,30);
  110.  
  111.  cptr = t;         /* point to beginning of buffer */
  112.  /*** Load Instrament Name ***/
  113.  memcpy(&inst->Name,cptr,22);
  114.  memcpy(&inst->Name[22],"\0",1);
  115.  cptr += 22;
  116.  
  117.  /*** Get Instrament Length ***/
  118.  inst->Len = Con_Word(cptr); /* correct word */
  119.  cptr += 2;
  120.  
  121.  * SLMR 2.1a * Beware of quantum ducks:  quark, quark.
  122.  
  123. --- SLMAIL v3.0  (#0272)
  124.  * Origin: Thunder Bay, Ontario, Canada (1:229/516)
  125. SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
  126. SEEN-BY: 153/752 154/40 77 157/110 159/100 125 430 575 950 203/23 209/209
  127. SEEN-BY: 261/1023 280/1 390/1 396/1 5 15 2270/1 2440/5 3603/20
  128.